package main

import (
	"context"
	"fmt"
	"gin-service/config"
	"gin-service/lib/GinSrv"
	"gin-service/lib/GormSrv"
	"gin-service/lib/MongoSrv"
	"gin-service/lib/RedisSrv"
)

func main() {
	configData := config.GetConfig()

	mysql := GormSrv.GormInit(configData["mysql"])
	redis := RedisSrv.RedisInit(configData["redis"])
	mongodb := MongoSrv.MongoInit(configData["mongodb"])
	defer func() {
		fmt.Println("db will be closed")
		_ = mysql.Close()
		_ = redis.Close()
		_ = mongodb.Disconnect(context.Background())
	}()

	GinSrv.GinInit(GinSrv.RoutersCollect, configData["gin"])
}
